package com.yami.shop.multishop.controller;

import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.dto.user.RegisterRongReqDTO;
import com.yami.shop.security.multishop.util.SecurityUtils;
import com.yami.shop.service.impl.RongYunUserServiceImpl;
import com.yami.shop.sys.common.model.ShopEmployee;
import com.yami.shop.sys.common.service.ShopEmployeeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shop/melt/user")
@Tag(name = "融云用户管理")
public class MeltCloudUserController {

    @Autowired
    private RongYunUserServiceImpl userService;
    
    @Autowired
    private ShopEmployeeService shopEmployeeService;


    @GetMapping("/token")
    @Operation(summary =  "获取融云用户token", description = "获取融云用户token")
    public ServerResponseEntity getToken() throws Exception {
        String userId = SecurityUtils.getShopUser().getUserId();
        ShopEmployee employee = shopEmployeeService.getById(userId);
        RegisterRongReqDTO build = RegisterRongReqDTO.builder().id("shop_" + userId).name(employee.getNickname()).portrait("/2022/12/123.png").build();
        return userService.userRegister(build);
    }
    
}
